<template>
  <div class="dev-template-container" v-if="isDevelopment">
    <!-- 页面头部 -->
    <div class="page-header">
      <div class="header-background">
        <div class="bg-pattern"></div>
        <div class="bg-gradient"></div>
      </div>
      
      <div class="page-title">
        <div class="title-icon">
          <div class="icon-container">
            <el-icon size="20"><Document /></el-icon>
            <div class="icon-glow"></div>
          </div>
        </div>
        <div class="title-content">
          <div class="title-main">
            <h1>前端开发模版页面</h1>
            <div class="title-badge">
              <el-icon><Star /></el-icon>
              <span>DEV TEMPLATE</span>
            </div>
          </div>
          <p class="page-description">
            <el-icon><Setting /></el-icon>
            基于项目多个页面（Kafka Monitor、Jobs、StarRocks Tables、Reports等）开发经验，提供两种标准模式的完整演示页面
          </p>
          <div class="title-meta">
            <div class="meta-item">
              <el-icon><Document /></el-icon>
              <span>功能演示</span>
            </div>
            <div class="meta-item">
              <el-icon><Setting /></el-icon>
              <span>代码参考</span>
            </div>
            <div class="meta-item">
              <el-icon><Monitor /></el-icon>
              <span>样式规范</span>
            </div>
          </div>
        </div>
      </div>
      
      <div class="page-stats">
        <div class="stat-card active">
          <div class="stat-icon">
            <el-icon><Check /></el-icon>
          </div>
          <div class="stat-content">
            <div class="stat-number">{{ stats.active_count || 0 }}</div>
            <div class="stat-label">活跃</div>
            <div class="stat-trend">
              <el-icon><Menu /></el-icon>
              <span>正常</span>
            </div>
          </div>
        </div>
        
        <div class="stat-card monitored">
          <div class="stat-icon">
            <el-icon><View /></el-icon>
          </div>
          <div class="stat-content">
            <div class="stat-number">{{ stats.monitored_count || 0 }}</div>
            <div class="stat-label">监控中</div>
            <div class="stat-trend">
              <el-icon><Menu /></el-icon>
              <span>运行</span>
            </div>
          </div>
        </div>
        
        <div class="stat-card alert-enabled">
          <div class="stat-icon">
            <el-icon><Bell /></el-icon>
          </div>
          <div class="stat-content">
            <div class="stat-number">{{ stats.alert_enabled_count || 0 }}</div>
            <div class="stat-label">告警启用</div>
            <div class="stat-trend">
              <el-icon><Menu /></el-icon>
              <span>已开启</span>
            </div>
          </div>
        </div>
        
        <div class="stat-card alerting">
          <div class="stat-icon">
            <el-icon><Warning /></el-icon>
          </div>
          <div class="stat-content">
            <div class="stat-number">{{ stats.alerting_count || 0 }}</div>
            <div class="stat-label">告警中</div>
            <div class="stat-trend">
              <el-icon><Warning /></el-icon>
              <span>需关注</span>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- Tab 标签页 -->
    <el-tabs v-model="activeTab" class="report-tabs" @tab-change="handleTabChange">
      <el-tab-pane label="整合模式示例" name="full">
        <FullFeatureDemo 
          :kafka-configs="kafkaConfigs"
          :selected-config-id="selectedConfigId"
          @config-change="handleConfigChange"
        />
      </el-tab-pane>
      
      <el-tab-pane label="独立批量操作模式示例" name="batch">
        <BatchOnlyDemo />
      </el-tab-pane>
      
      <el-tab-pane label="字段设置演示" name="field">
        <FieldSettingsDemo />
      </el-tab-pane>
      
      <el-tab-pane label="高级筛选演示" name="filter">
        <AdvancedFilterDemo />
      </el-tab-pane>
      
      <el-tab-pane label="组件库演示" name="components">
        <ComponentsDemo />
      </el-tab-pane>
    </el-tabs>
  </div>
  
  <!-- 非开发环境提示 -->
  <div v-else class="not-dev-env">
    <el-empty description="此页面仅在开发环境显示" />
  </div>
</template>

<script setup>
import { ref, onMounted, computed } from 'vue'
import { 
  Document, Star, Setting, Monitor, Check, View, Bell, Warning, Menu, Clock
} from '@element-plus/icons-vue'
import FullFeatureDemo from './components/FullFeatureDemo.vue'
import BatchOnlyDemo from './components/BatchOnlyDemo.vue'
import FieldSettingsDemo from './components/FieldSettingsDemo.vue'
import AdvancedFilterDemo from './components/AdvancedFilterDemo.vue'
import ComponentsDemo from './components/ComponentsDemo.vue'
import { mockKafkaConfigs, mockStats } from './mock/data'

// 开发环境判断
const isDevelopment = computed(() => {
  return import.meta.env.DEV || import.meta.env.MODE === 'development'
})

const activeTab = ref('full')
const kafkaConfigs = ref([])
const selectedConfigId = ref(null)
const stats = ref(mockStats)

// 初始化
onMounted(() => {
  // 模拟加载配置列表
  kafkaConfigs.value = mockKafkaConfigs
  if (kafkaConfigs.value.length > 0) {
    selectedConfigId.value = kafkaConfigs.value[0].id
  }
})

const handleTabChange = (tabName) => {
  console.log('切换Tab:', tabName)
}

const handleConfigChange = (configId) => {
  selectedConfigId.value = configId
}
</script>

<style scoped>
.dev-template-container {
  padding: 0;  /* 页面容器不设置内边距，距离菜单栏的20px由布局的.content提供 */
}

/* 页面头部样式 - 参考KafkaMonitor */
.page-header {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding: 20px 24px;
  border-radius: 12px;
  overflow: hidden;
  color: #303133;
  min-height: 120px;
  border: 1px solid #e4e7ed;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.header-background {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 0;
}

.bg-gradient {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  opacity: 1;
}

.bg-pattern {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: 
    radial-gradient(circle at 20% 80%, rgba(64, 158, 255, 0.05) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(64, 158, 255, 0.05) 0%, transparent 50%);
  animation: patternMove 30s ease-in-out infinite;
}

@keyframes patternMove {
  0%, 100% { transform: translateX(0) translateY(0); }
  25% { transform: translateX(-10px) translateY(-5px); }
  50% { transform: translateX(5px) translateY(-10px); }
  75% { transform: translateX(-5px) translateY(5px); }
}

.page-title {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 24px;
  flex: 1;
}

.title-icon .icon-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #409eff 0%, #66b3ff 100%);
  border-radius: 8px;
  color: white;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(64, 158, 255, 0.2);
}

.title-icon .icon-container:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 16px rgba(64, 158, 255, 0.3);
}

.title-content {
  flex: 1;
}

.title-main {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}

.title-main h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  color: #303133;
}

.title-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: linear-gradient(135deg, #409eff 0%, #66b3ff 100%);
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  color: white;
  text-transform: uppercase;
}

.page-description {
  margin: 0 0 12px 0;
  color: #606266;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.title-meta {
  display: flex;
  gap: 20px;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #909399;
  font-size: 12px;
  font-weight: 500;
}

.page-stats {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 20px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #fff;
  border-radius: 8px;
  border: 1px solid #e4e7ed;
  transition: all 0.3s ease;
  min-width: 120px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border-color: #409eff;
}

.stat-card.active .stat-icon {
  background: rgba(103, 194, 58, 0.1);
  color: #67c23a;
}

.stat-card.monitored .stat-icon {
  background: rgba(64, 158, 255, 0.1);
  color: #409eff;
}

.stat-card.alert-enabled .stat-icon {
  background: rgba(230, 162, 60, 0.1);
  color: #e6a23c;
}

.stat-card.alerting .stat-icon {
  background: rgba(245, 108, 108, 0.1);
  color: #f56c6c;
}

.stat-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  font-size: 16px;
}

.stat-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-number {
  font-size: 20px;
  font-weight: 700;
  color: #303133;
}

.stat-label {
  font-size: 12px;
  color: #606266;
}

.stat-trend {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: #909399;
}

/* Tab样式 - 参考Reports */
.report-tabs {
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.report-tabs :deep(.el-tabs__item) {
  font-size: 16px;
  font-weight: 500;
}

.report-tabs :deep(.el-tabs__item.is-active) {
  color: #409eff;
}

.report-tabs :deep(.el-tabs__active-bar) {
  background-color: #409eff;
}

.not-dev-env {
  padding: 100px 20px;
  text-align: center;
}
</style>

